package com.retailshop.shopuser.service.impl;

import com.retailshop.shopuser.common.MD5Util;
import com.retailshop.shopuser.entity.Admin;
import com.retailshop.shopuser.mapper.AdminMapper;
import com.retailshop.shopuser.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("AdminService")
public class AdminServiceImpl implements AdminService {

    @Autowired
    AdminMapper adminMapper;

    @Override
    public Admin selectByPrimaryKey(Integer id) {
        return adminMapper.selectByPrimaryKey(id);
    }

    @Override
    public Admin selectLogin(String us,String pwd) {
        System.out.println(us);
        System.out.println(pwd);
        Admin admin =adminMapper.selectLogin(us);
        boolean flag = false;
        try {
            flag = MD5Util.validPassword(pwd, admin.getPwd());
        }catch (Exception ex)
        {}

        if(flag)
        {
            return admin;
        }

        return null;
    }

}